package org.vectrics.recruiter.struts.tag;

import java.util.ArrayList;
import java.util.List;
import java.util.Set;

import org.vectrics.common.pagelist.PageList;
import org.vectrics.hibernate.ThreadProperties;
import org.vectrics.provider.CoreServiceLocator;
import org.vectrics.recruiter.RecruitServiceLocator;
import org.vectrics.recruiter.job.JobCandidate;
import org.vectrics.recruiter.job.JobCandidateCriteria;
import org.vectrics.user.Person;



public class JobCandidatePageList extends PageList {
	private JobCandidateCriteria criteria = null;
	
	/**
	 * 
	 */
	public JobCandidatePageList(JobCandidateCriteria criteria) {
		super();
		this.criteria = criteria;
		Person authPerson = ThreadProperties.getPerson();
		Set domains = CoreServiceLocator.getPersonService()
				.findDomainsWithUserPrivilege(authPerson, JobCandidate.PRIVILEGE_VIEW_CANDIDATES);
		criteria.setDomains(domains);
	}
	
	
	public int getTotalElementCount() {
		return(RecruitServiceLocator.getJobProvider().findJobCandidatesCount(criteria));
	}

	/* (non-Javadoc)
	 * @see org.vectrics.common.pagelist.PageList#getKeys()
	 */
	public List getElements(int start, int end) {
		List list = new ArrayList();
		
		list.addAll(RecruitServiceLocator.getJobProvider().findJobCandidates(criteria, start, end));
		return(list);
	}

}
